import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { JwtModule } from '@nestjs/jwt';
import Utils from '../../utils';
import { APP_GUARD } from '@nestjs/core';
import { AuthGuard } from 'src/guard/auth.guard';
import { TypeOrmModule } from '@nestjs/typeorm';
import User from './user.entity';



@Module({
  imports: [
    HttpModule,
    JwtModule.register({
      secret: 'dsh',
      signOptions: { expiresIn: '24h' },
    }),
    TypeOrmModule.forFeature([User]),
    TypeOrmModule.forRoot({
        type: 'mysql',  // 数据库类型
        host: 'dingshaohua.mysql.rds.aliyuncs.com', // 域名
        port: 3306,     // 端口
        username: 'root', // 数据库名字
        password: '@Dsh742308560',  // 数据库密码
        database: 'chat_gpt',    // 库名
        // entities: [User],  
        synchronize: true,
      autoLoadEntities: true,
    })
  ],
  controllers: [AppController],
  providers: [
    AppService,
    Utils,
    {
      provide: APP_GUARD,
      useClass: AuthGuard,
    },
  ],
})
export class AppModule {}
